<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>菜单管理<!--{if $info['name']}-->--{$info['name']}<!--{/if}--></title>
        <link href="style/default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="./javascript/jquery.js">
        </script>
        <script type="text/javascript" src="./javascript/javascript.js">
        </script>
        <script type="text/javascript">
            var method = eval('({Action_getMethodJson:true})');
            $(function(){
                $('select[name="sort_id"]').click(function(){
                    $('input:radio[name="sort"]').eq(2).attr('checked', true);
                });
                $('select[name="action"]').append('<option></option>');
                for (var model in method) {
                    if (model == '{$info["action"]}') {
                        $('select[name="action"]').append('<option value="' + model + '" selected>' + model + '</option>');
                    }
                    else {
                        $('select[name="action"]').append('<option value="' + model + '">' + model + '</option>');
                    }
                }
                getMethodSelect('{$info["method"]}');
            });
            function getMethodSelect(mh){
                var model = $('select[name="action"]').val();
                $('select[name="method"]').html('<option value=""></option>');
                for (var i in method[model]) {
                    if (mh == method[model][i]) {
                        $('select[name="method"]').append('<option selected>' + method[model][i] + '</option>');
                    }
                    else {
                        $('select[name="method"]').append('<option>' + method[model][i] + '</option>');
                    }
                }
            }
            
            function addMethod(){
                var html = '<dd>';
                html += $('select[name="action"]').val() + '-&gt;' +
                $('select[name="method"]').val();
                html += '<input type="hidden" name="methods[]" value="' +
                $('select[name="action"]').val() +
                '.' +
                $('select[name="method"]').val() +
                '"/>';
                html += '<img class="but" src="images/delete.gif" onclick="delMethod(this)">';
                html += '<dd>';
                $('dl#method').append(html);
            }
            
            function delMethod(obj){
                $(obj).parent().remove();
            }
        </script>
    </head>
    <body>
        <!--{include nav.html}-->
        <div id="main">
            <div style="float: left;">
                <table class="list">
                    <tr>
                        <th>
                            菜单名
                        </th>
                        <th>
                            打开
                        </th>
                        <th>
                            排序
                        </th>
                        <th class="but">
                            <a href="{$url}&amp;m=add"><img src="images/new.gif"></a>
                        </th>
                    </tr><!--{foreach $list $row}-->
                    <tr id="list_{$row['id']}" {if $row['id']==$_GET[
 'id']}class="selected"{/if}>
                        <td>
                            <!--{if $row['parent_id']}-->&nbsp;&nbsp;&nbsp;<!--{/if}--><!--{$row['name']}-->
                        </td>
                        <td>
                            <!--{$row['action']}--><!--{if $row['method']}-->::<!--{$row['method']}--><!--{/if}-->
                        </td>
                        <td>
                            <!--{$row['sort']}-->
                        </td>
                        <td class="but" align="center">
                            <a href="{$url}&m=edit&id={$row['id']}"><img src="images/edit.gif"></a><a href="{$url}&m=del&id={$row['id']}"><img src="images/delete.gif"></a>
                        </td>
                    </tr><!--{/foreach}-->
                </table>
                <div>
                    {$mulitpage}
                </div>
            </div>
            <div style="float: left; margin-left: 5px;">
                <form method="post" action="{$url}&amp;m={$_GET['m']}&amp;id={$_GET['id']}">
                    <table class="list">
                        <tr>
                            <th colspan="2">
                                <!--{if $_GET['m']=='edit'}-->修改<!--{elseif $_GET['m']=='del'}-->删除<!--{else}--> 增加<!--{/if}--> 菜单
                            </th>
                        </tr>
                        <!--{if $_GET['m']=='del'}-->
                        <tr>
                            <td align="center" colspan="2">
                                确认真的要删除<b>{$info['name']}</b>菜单 
                                <br>
                                &nbsp; <span class="error">删除后该菜单的信息将不能恢复</span>
                            </td>
                        </tr>
                        <tr>
                            <th colspan="2">
                                <input type="submit" name="confirm" value="删除"><input type="submit" name="cancel" value="取消">
                            </th>
                        </tr><!--{else}-->
                        <tr>
                            <th>
                                菜单名
                            </th>
                            <td>
                                <input type="text" name="name" value="{$info['name']}" class="short">
                            </td>
                        </tr>
                        <tr>
                            <th>
                                打开
                            </th>
                            <td>
                                <dl id="method">
                                    <!--{foreach $info['method'] $model $methods}-->
                                    <!--{foreach $methods $method}-->
                                    <dd>
                                        {$model}-&gt;{$method} <input type="hidden" name="methods[]" value="{$model}.{$method}" /><img class="but" src="images/delete.gif" onclick="delMethod(this)">
                                    </dd><!--{/foreach}-->
                                    <!--{/foreach}-->
                                </dl>
                                <select name="action" onchange="getMethodSelect('')">
                                </select>
                                <select name="method">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                上级菜单
                            </th>
                            <td>
                                <!--{Html_getSelect_lib:$top,$info['parent_id'],array('name'=>'parent_id'),array('')}-->
                            </td>
                        </tr>
                        <tr>
                            <th>
                                排序
                            </th>
                            <td>
                                <input type="text" name="sort" value="{$info['sort']}" class="short">
                            </td>
                        </tr>
                        <tr>
                            <th colspan="2">
                                <input type="submit" name="save" value="保存"><input type="submit" name="cancel" value="取消"><!--{if $_GET['m']=='edit'}-->
                                <input type="submit" name="del" value="删除"><!--{/if}-->
                            </th>
                        </tr><!--{/if}-->
                    </table>
                </form>
            </div>
        </div>
    </body>
</html>